package com.sc.nft.entity.vo;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class LockOrderVO {

    @ApiModelProperty("订单集合")
    private List<Long> orderIds=new ArrayList<>();

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("过期时间")
    private Date expirationTime;

    @ApiModelProperty("商品总价")
    private String money="0.00";

    @ApiModelProperty("系统当前时间")
    private Date nowDate;
    @ApiModelProperty("订单列表")
    private List<BrandOrderListVO> orderList;

    @ApiModelProperty("总库存")
    private Integer  sumCount;

    public void addMoney(BigDecimal money) {
        // 额度保留2位小数并且转换String
        this.money = Convert.toBigDecimal(this.money).add(money.setScale(2, BigDecimal.ROUND_DOWN)).toPlainString();
    }

    public void setMoney(BigDecimal money) {
        // 额度保留2位小数并且转换String
        this.money = money.setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
    }


    public String getNowDate(){
        return DateUtil.formatDateTime(this.nowDate);
    }


    public Date getNowDateSourceType(){
        return this.nowDate;
    }

}
